
alter  proc sp_save_odm_list
@customerId int,
@odmId int
as
begin

	declare @status_id int
	
	if(( select count(*) from Customer_odm_relationship where ParentCustomer_ID = @customerId and ODMCustomer_ID = @odmId) = 0)
	begin
		select @status_id = RelationshipStatus_ID from Customer_Relationship_Status where Name = 'Active'
		--print 'This is test message'
		insert into customer_odm_relationship(ParentCustomer_ID, ODMCustomer_ID, RelationshipStatus_ID) values (@customerId, @odmId, @status_id)
	end
	else
	begin
		select @status_id = RelationshipStatus_ID from Customer_Relationship_Status where Name = 'Active' -- Added by Veeru ( 29th Nov 2004)
		update Customer_odm_relationship set ParentCustomer_ID = @customerId, ODMCustomer_ID = @odmId, RelationshipStatus_ID = @status_id where ParentCustomer_ID = @customerId and ODMCustomer_ID = @odmId
	end		
end
